
export { };
// 4.单例和构建分离模式
interface Window{
  new(): Window;
}
let Window = function () {
  
};
Window.prototype.hello = function () {
  console.log('hello---4');
};

let createInstance = (function () {
  let instance: Window;
  return function () {
    if (!instance) {
      console.log('4   没有走缓存');
      return instance = new (Window as any);
    };
    console.log('4  走缓存');
    return instance
  }
})();
//4 测试单例
let w1 = createInstance();
let w2 =createInstance();
console.log(`4 两个实例是否一样${w1 == w2}`)
